Skip to main content
Version: 16.9.0

memory_usage

psutil

bytes_to_gigibytes

def bytes_to_gigibytes(num_bytes: int) -> float

get_total_memory_usage_in_gib

def get_total_memory_usage_in_gib(pid: Optional[int]) -> float

Calculate the total memory usage of a process and its child processes in gigibytes (GiB).

Arguments:

  • pid int, optional - The process ID for which memory usage is to be calculated. If None, returns 0.0.

Returns:

  • float - The total memory usage of the process and its children in GiB. If pid is None, returns 0.0.

get_available_memory_bytes

def get_available_memory_bytes() -> int

Returns the available memory in bytes.

get_available_memory_gib

def get_available_memory_gib() -> float

Returns the available memory in gigabytes.